package test.Kama240718.ACM02;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main{

    //145. 数组子序列的排列
    public static void main(String[] args) {
        long MOD = 1000000007L;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        //java一个一个读入到数组的话总体要 2200ms+。读入一行字符串 再用空格分割 总体就1900ms+
        sc.nextLine();
        String str = sc.nextLine();
        String[] sp = str.split(" ");
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) nums[i] = Integer.parseInt(sp[i]);
        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {map.put(nums[i], map.getOrDefault(nums[i], 0) + 1);}
        long ans = 0L;
        long k = 1L;
        for (Integer i = 1; i <= n; i++) {
            if (!map.containsKey(i)) {break;}
            k=k*map.get(i)%MOD;
            ans = (ans + k)%MOD;
        }
        System.out.print((int)ans);
    }
}